<!-- 赞赏 -->

<script>
function shang(article_id,money,to_uid,headimgurl,zanshang_desc,zanshang_btn2,zanshang_type){
	
	if(money<=0){
		showerror("金额必须大于0");
		return false;
	}
	
	if(!checkCurrency(money)){
		showerror("金额输入有误");
		return false;
	}
	
	//alert(goods_id);
	var txt = '<div class="page_msg">'
		+'<div class="icon_area" style="margin-top:5px"><i class="p-article-avatar"><img src="'+headimgurl+'" onerror="javascript:this.src=\'__STATIC__mobile/images/logo.jpg\';"></i></div>'
		+'<div class="text_area">'
			+'<h1 id="" class="title" style="font-size:16px;margin-top:10px">'+zanshang_desc+'</h1>'
			+'<p id="suc_desc" class="desc" style="margin-top:25px;">'+'<span style="font-size:40px;">'+money+'</span>'
			+'<em style="font-size:12px;">元</em></p>'
		//	+'<p style="font-size:12px;margin-top:10px;"><em >其他金额</em></p>'
			+'</div>'
		+'<div class="opr_area">'
			+'<a href="javascript:createshang('+article_id+','+zanshang_type+','+money+','+to_uid+');" class="mbtn btn-big" style="background-color: #f39800;color:#fff;">'+zanshang_btn2+'<span style="font-size:12px;"></span></a></span>'
		+'</div>'
	+'</div>';
	//信息框

	
	//信息框
	layer.open({
		title: ['请输入您的手机号码','display:none;'],
	    content: txt,
	  //  shade: false,
	    shadeClose: true,//点击遮罩是否关闭对话框
	    style: 'color:#fff;width:92%;max-width: 350px;background-color:#ea3b26;  background: url(/Static/mobile/img/ad.png) no-repeat;background-size:100%;',
	});
	
}


function createshang(article_id,zanshang_type,money,to_uid){
	
	$.ajax({
		url : '/mobile/order/charge/?type='+zanshang_type+'&article_id='+article_id,
		type : 'post',
		data : {'money':money,'to_uid':to_uid},
		dataType : 'json',
	//	async : false,
		success : function(data) {
			//关闭正在加载
			layer.closeAll();//关闭所有
			
			if(data.url){
				var urls = data.url;
			}else{
				var urls = '';
			}

			if(data.ret == 0){
				// 成功
				var order_id = data.url;
				jsApiCall2(data.data,order_id)
				
			}else{
				// 失败
				showerror(data.msg,urls);
			}
		},
		beforeSend:function(){
			//正在加载
			layer.open({
		        type: 2,
		        shade: true,
		        shadeClose: false,
		    });
			
       },
       error: function() {
		   //关闭正在加载
    	   layer.closeAll();//关闭所有
		   showerror("网络错误,请重试");
       }
       
	});
}


function jsApiCall2(jsparam,order_id)
{
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		jsparam,
		function(res){
			WeixinJSBridge.log(res.err_msg);
			 if(res.err_msg == "get_brand_wcpay_request:ok" ) {

				//弹窗感谢
				 showsuccess("感谢~么么哒");
				 
			  // location.href = "/mobile/order/payok/?order_id="+order_id;
			 
			 }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
			 
				//alert("未支付成功,请重试");
			 }
			//alert(res.err_msg);

		}
	);
}

</script>